#!/usr/bin/env python

ACCOUNT_FILE = 'account.txt'
PROFILE_INTERVAL = 60

import dictbot
import profiler


def read_AccountInfo(accountFile):
	"Read configuration settings for all accounts"
	accInfo = {}
	for line in open(accountFile).readlines():
		line = line.strip()
		if len(line) > 0 and not line.startswith('#'):	# Not a blank line or a comment
			key, value = line.split(':')
			key = key.strip().lower()
			value = value.strip()
			if accInfo.has_key(key):
				accInfo[key].append(value);
			else:
				accInfo[key] = [value]
	return accInfo


if __name__ == '__main__':
	localBots = []
	accInfo = read_AccountInfo(ACCOUNT_FILE)
	dictbot.DictBot.admins = accInfo['admin']

	domain = accInfo['domain'][accNum]
	username = accInfo['username'][accNum]
	password = accInfo['password'][accNum]
	url = accInfo['url'][accNum]
	port = int(accInfo['port'][accNum])
	bot = dictbot.DictBot(domain, username, password, url, port)
	bot.start()

	profiler = profiler.Profiler(bot, PROFILE_INTERVAL)
	profiler.start()
	bot.join()
	profiler.exist = False
	profiler.join()
